package com.cskaoyan.controller;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.FeedbackVo;
import com.cskaoyan.service.FeedbackService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/feedback")
public class WxFeedbackController {

    @Autowired
    FeedbackService feedbackService;
    //意见反馈提交
    @PostMapping("submit")
    public BaseRespVo submit(@RequestBody FeedbackVo feedbackVo){
        //意见反馈功能需要登录才能进行
        Subject subject = SecurityUtils.getSubject();
        if(subject.isAuthenticated()){
            Integer userId = (Integer) subject.getPrincipal();
            BaseRespVo baseRespVo = feedbackService.submit(feedbackVo, userId);
            return baseRespVo;
        }else {
            return BaseRespVo.unAuthc();
        }
    }

}
